package com.itheima.config;

import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.OptimisticLockerInnerInterceptor;
import com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: 斌
 * @DateTime: 2023年02月05日  14:13:38
 * @Description: com.itheima.config
 * @Version: 1.0
 */
@Slf4j
@Configuration
public class MPConfig {

    @Bean
    public MybatisPlusInterceptor  mybatisPlusInterceptor(){
        log.info("MyBatisPlus分页拦截器开始执行.....");
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new PaginationInnerInterceptor());
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }
}
